﻿// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
// Licensed under the LGPL License, Version 3.0. See License.txt in the project root for license information.
// Website: https://admin.blazor.zone

using BlazorAdmin.Models;
using BlazorAdmin.Interface;
using BootstrapBlazor.Components;
using BlazorAdmin.Web.Shared.Extensions;
using BlazorAdmin.Web.Shared.Models;
using BlazorAdmin.Web.Shared.Utils;
using Microsoft.AspNetCore.Components;
using System.Diagnostics.CodeAnalysis;

namespace BlazorAdmin.Web.Shared.Components
{
    /// <summary>
    /// 
    /// </summary>
    public partial class MenusSearch
    {
        [NotNull]
        [Inject]
        private IDict? DictService { get; set; }

        private IEnumerable<SelectedItem>? CategoryItems { get; set; }

        private IEnumerable<SelectedItem>? ResourceItems { get; set; }

        private List<SelectedItem>? AppItems { get; set; }

        private List<SelectedItem>? TargetItems { get; set; }

        /// <summary>
        /// 
        /// </summary>
        [Parameter]
        [NotNull]
        public MenusSearchModel? Value { get; set; }

        /// <summary>
        /// 
        /// </summary>
        [Parameter]
        public EventCallback<MenusSearchModel> ValueChanged { get; set; }

        /// <summary>
        /// 
        /// </summary>
        protected override void OnInitialized()
        {
            base.OnInitialized();

            TargetItems = new List<SelectedItem>()
        {
            new SelectedItem("", "全部")
        };
            TargetItems.AddRange(LookupHelper.GetTargets());

            AppItems = new List<SelectedItem>()
        {
            new SelectedItem("", "全部")
        };
            AppItems.AddRange(DictService.GetApps().ToSelectedItemList());

            ResourceItems = typeof(SysEnumResource).ToSelectList(new SelectedItem("", "全部"));
            CategoryItems = typeof(SysEnumNavigationType).ToSelectList(new SelectedItem("", "全部"));
        }
    }
}